home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ExtensionsStrip.h
-
- Contains: Extensions Strip Specific Interfaces plus the commented out
- Universal ControlStrip.h Interfaces.
-
- Version: Technology: System 7.1+ (System 7.5+ preferred)
- Package: Extensions Strip 1.0
-
- Copyright: © 1995 by Ammon Skidmore, Skidperfect Software Inc.
- All rights reserved.
-
- Bugs?: If you find a problem, or have a criticism (they are welcome)
- with this file, please inform the author at the following address:
- Internet: skidperfect@kagi.com
- */
-
- #ifndef __EXTENSIONSSTRIP__
- #define __EXTENSIONSSTRIP__
-
- #ifndef __CONTROLSTRIP__
- #include <ControlStrip.h>
- #endif
-
- #ifndef __APPLEEVENTS__
- #include <AppleEvents.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
-
- /*********************************************************************************************
-
- Selector calls to the module.
-
- *********************************************************************************************/
- enum {
- // sdevInitModule = 0, /* initialize the module */
- // sdevCloseModule = 1, /* clean up before being closed */
- // sdevFeatures = 2, /* return feature bits */
- // sdevGetDisplayWidth = 3, /* returns the width of the module's display */
- // sdevPeriodicTickle = 4, /* periodic tickle when nothing else is happening */
- /* NB: you can return the special result values. */
- // sdevDrawStatus = 5, /* update the interface in the Control Strip*/
- // sdevMouseClick = 6, /* user clicked on the module's display area in the Control Strip */
- /* NB: you can return the special result values. */
- // sdevSaveSettings = 7, /* saved any changed settings in module's preferences file */
- // sdevShowBalloonHelp = 8, /* puts up a help balloon, if the module has one to display */
-
- sdevInAppContext = 2000, /* called only once after the module specifically
- requested to be executed from inside Extension
- Strip's context. NB: you can return the special
- result values. */
-
- sdevInterceptedEvent = 2001, /* if the module returned the sdevInterceptAllEvents
- flag in its features, then this selector
- will get called before _each_ event is processed
- by Extensions Strip. Meant to be used with
- _SBGetCurrentEvent so each event can be looked at,
- and modified if necessary (to prevent passing.)
- NB: you can return the special result values. */
-
- sdevDragAccept = 2002, /* return 0 if you accept the current drag, and
- 1 if you do not. Modules that do not have any
- drag handlers will never get this called.
- NB: sdevDragAccept is only called from within
- Extensions Strip's dragTrackingInWindow. So it
- is recommended to only check if you accept the drag
- from within your dragTrackingEnterWindow, and then
- set a global var that you can pass onto ES. */
-
- sdevEventMask = 2003 /* if the module returned the sdevInterceptAllEvents
- flag in its features, this selector will get
- called to find the event mask to use. Return your
- mask as the result value of the sdev call.
- sdevEventMask is called once upon initialization,
- and every time sdevFeaturesChange is requested. */
- };
-
- /*********************************************************************************************
-
- Features supported by the module. If a bit is set, it means that feature is supported.
- All undefined bits are reserved for future use by Apple, and should be set to zero.
-
- *********************************************************************************************/
- /*
- Tip: if you clear sdevWantMouseClicks and set sdevDontAutoTrack, your module
- will receive clicks and Extensions Strip (plus Desktop Strip) will not
- auto-hilite your module.
- */
- enum {
- // sdevWantMouseClicks = 0, /* notify the module of mouseDown events */
- // sdevDontAutoTrack = 1, /* call the module to do mouse tracking */
- // sdevHasCustomHelp = 2, /* module provides its own help messages */
- // sdevKeepModuleLocked = 3, /* module needs to be locked in the heap */
-
- sdevHasDragHandlers = 31, /* module has installed a drag tracking and/or
- receive handler in the Strip window. */
-
- sdevDontPeriodicTickle = 30, /* module does not require any idle time so
- by setting this bit it will never get
- called with the sdevPeriodicTickle
- selector. Note that you can set this along
- with the sdevInterceptAllEvents bit (if you want)
- and sdevInterceptedEvent will still get called.
- So be nice and set this to help speed up idle
- time processing. */
-
- sdevInterceptAllEvents = 29 /* module wants to be executed before each
- event passes through Extension Strip's
- jGNE filter. Because the module is allowed
- to modify every event, there is no more need
- for modules, such as Terminator Strip, to
- install their own jGNE filters!
- NB: You need to return an event mask when your
- module is called by the sdevEventMask selector. */
- };
-
- /*********************************************************************************************
-
- Special result values returned by the sdevPeriodicTickle and sdevMouseClick selectors.
- If a bit is set, the module can request that a specific function is performed by
- the Control Strip. A result of zero will do nothing. All undefined bits are reserved
- for future use by Apple, and should be set to zero.
-
- *********************************************************************************************/
- /*
- Note: these values can also be returned by the sdevInAppContext and
- sdevInterceptedEvent selectors.
- */
- enum {
- // sdevResizeDisplay = 0, /* resize the module's display */
- // sdevNeedToSave = 1, /* need to save changed settings, when convenient */
- // sdevHelpStateChange = 2, /* need to update the help message because of a state change */
- // sdevCloseNow = 3, /* close a module because it doesn't want to stay around */
-
- sdevQueueModule = 31, /* module needs to be executed from within
- Extension Strip's context: useful for
- things like sending AppleEvents or
- creating and tracking new drags. */
-
- sdevFeaturesChange = 30 /* module wants to change its feature flags. Useful
- for changing clickable state of the module and
- for locking/unlocking the sdev code. */
- };
-
- /*********************************************************************************************
-
- miscellaneous
-
- *********************************************************************************************/
- enum {
- // sdevFileType = 'sdev', /* module file and code resource type */
- sdevTypeCodePPC = 'Sdev' /* resource type for module's PPC code */
- };
-
- //
-
- //enum {
- // sdevMenuItemMark = '•'
- //};
-
- /* direction values for SBDrawBarGraph*/
- //enum {
- // BarGraphSlopeLeft = -1, /* max end of sloping bar graph is on the left*/
- // BarGraphFlatRight = 0, /* max end of flat bar graph is on the right*/
- // BarGraphSlopeRight = 1 /* max end of sloping bar graph is on the right*/
- //};
-
- //
-
- enum {
- //
- gestaltExtensionsStripAttr = 'CsEs', /* returns Extensions Strip's attributes */
-
- /* currently returned bits from gestaltExtensionsStripAttr: */
- gestaltExtensionsStripExists = 0, /* Extensions Strip is currently launched */
-
-
- //
- gestaltDesktopStripAttr = 'CsWT' /* returns the Mice and Men's Desktop Strip
- attributes which are supported by
- Extensions Strip. See Desktop Strip's
- documentation for details about the bits */
- };
-
- //
-
- typedef unsigned long ModuleReference;
-
- //
-
- typedef pascal void (*SBQueueProcPtr)(unsigned long refCon);
-
- #if GENERATINGCFM
- typedef UniversalProcPtr SBQueueUPP;
- #else
- typedef SBQueueProcPtr SBQueueUPP;
- #endif
-
- enum {
- uppQueueProcProcInfo = kPascalStackBased | STACK_ROUTINE_PARAMETER(1, kFourByteCode)
- };
-
- #if GENERATINGCFM
- #define NewSBQueueProcProc(userRoutine) \
- (SBQueueUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppAEIdleProcInfo, GetCurrentArchitecture())
- #else
- #define NewSBQueueProcProc(userRoutine) \
- ((SBQueueUPP) (userRoutine))
- #endif
-
- //
-
- /*********************************************************************************************
-
- utility routines to provide standard interface elements and support for common functions
-
- *********************************************************************************************/
-
- // //
- // //
- // All routines are documented as to whether the Extensions Strip implementation //
- // of them they may move memory. You can trust that a routine that says it //
- // will not move memory in this version, will not move memory in future versions.//
- // Note though, that some Universal Control Strip traps may move memory under //
- // Control/Desktop Strip but not in Extensions Strip (such as //
- // _SBIsControlStripVisible and _SBShowHideControlStrip.) //
- // //
- // //
-
- // =========================================================
- // ========== Universal Control Strip traps ================
- // =========================================================
- /*
- // Will not move memory. //
- extern pascal Boolean SBIsControlStripVisible(void)
- TWOWORDINLINE(0x7000, 0xAAF2);
-
- // Will not move memory. //
- extern pascal void SBShowHideControlStrip(Boolean showIt)
- THREEWORDINLINE(0x303C, 0x0101, 0xAAF2);
-
- // Will not move memory. //
- extern pascal Boolean SBSafeToAccessStartupDisk(void)
- TWOWORDINLINE(0x7002, 0xAAF2);
-
- // May move memory! //
- extern pascal short SBOpenModuleResourceFile(OSType fileCreator)
- THREEWORDINLINE(0x303C, 0x0203, 0xAAF2);
-
- // May move memory! //
- extern pascal OSErr SBLoadPreferences(ConstStr255Param prefsResourceName, Handle *preferences)
- THREEWORDINLINE(0x303C, 0x0404, 0xAAF2);
-
- // May move memory! //
- extern pascal OSErr SBSavePreferences(ConstStr255Param prefsResourceName, Handle preferences)
- THREEWORDINLINE(0x303C, 0x0405, 0xAAF2);
-
- // Will not move memory. //
- extern pascal void SBGetDetachedIndString(StringPtr theString, Handle stringList, short whichString)
- THREEWORDINLINE(0x303C, 0x0506, 0xAAF2);
-
- // May move memory! //
- extern pascal OSErr SBGetDetachIconSuite(Handle *theIconSuite, short theResID, unsigned long selector)
- THREEWORDINLINE(0x303C, 0x0507, 0xAAF2);
-
- // May move memory! //
- extern pascal OSErr SBTrackPopupMenu(const Rect *moduleRect, MenuHandle theMenu)
- THREEWORDINLINE(0x303C, 0x0408, 0xAAF2);
-
- // May move memory! //
- extern pascal OSErr SBTrackSlider(const Rect *moduleRect, short ticksOnSlider, short initialValue)
- THREEWORDINLINE(0x303C, 0x0409, 0xAAF2);
-
- // May move memory! //
- extern pascal OSErr SBShowHelpString(const Rect *moduleRect, StringPtr helpString)
- THREEWORDINLINE(0x303C, 0x040A, 0xAAF2);
-
- // Will not move memory. //
- extern pascal short SBGetBarGraphWidth(short barCount)
- THREEWORDINLINE(0x303C, 0x010B, 0xAAF2);
-
- // May move memory! //
- extern pascal void SBDrawBarGraph(short level, short barCount, short direction, Point barGraphTopLeft)
- THREEWORDINLINE(0x303C, 0x050C, 0xAAF2);
-
- // May move memory! //
- extern pascal void SBModalDialogInContext(ModalFilterUPP filterProc, short *itemHit)
- THREEWORDINLINE(0x303C, 0x040D, 0xAAF2);
- */
-
- // =======================================================
- // ========== Extensions Strip ONLY traps ================
- // =======================================================
-
- /* Strip Window Utilities */
-
- // returns: true = vertical; false = horizontal
- // // Will not move memory. //
- extern pascal Boolean SBIsControlStripVertical(WindowRef stripPort)
- TWOWORDINLINE(0x70FF, 0xAAF2);
-
- // returns pixel depth of the monitor this Strip window is in (always a power of 2)
- // // Will not move memory. //
- extern pascal short SBGetControlStripDepth(WindowRef stripPort)
- TWOWORDINLINE(0x70FE, 0xAAF2);
-
- // returns the current normal back color of this Strip window
- // // Will not move memory. //
- extern pascal void SBGetStripBackColor(RGBColor *color, WindowRef stripPort)
- TWOWORDINLINE(0x70FD, 0xAAF2);
-
- //returns the current back color of this Strip window when a module is selected
- // // Will not move memory. //
- extern pascal void SBGetStripSelectedColor(RGBColor *color, WindowRef stripPort)
- TWOWORDINLINE(0x70FC, 0xAAF2);
-
- /* Module Utilities */
-
- // returns a reference number that all of the Module Utilities need
- /* NB: since SBGetMyReferenceNum can ONLY be called from sdevInitModule,
- you should save its value into your globals if you are going to use
- one of the Module Utilities later, such as inside a tracking handler. */
- // Also, the reference number will always be non-zero.
- // // Will not move memory. //
- extern pascal ModuleReference SBGetMyReferenceNum(void)
- TWOWORDINLINE(0x70FB, 0xAAF2);
-
- // total window space taken up by a module. Useful for drag-n-drop calculations
- // note that this rect will always be larger than the module's statusRect.
- // // Will not move memory. //
- extern pascal void SBGetTotalModuleBounds(Rect *bounds, WindowRef stripPort, ModuleReference moduleRefNum)
- TWOWORDINLINE(0x70FA, 0xAAF2);
-
- // returns the statusRect of the module. Very useful for drag-n-drop routines
- // because you no longer have to constantly set a global rectangle variable to
- // hold the current location of the module in the Strip window.
- // // Will not move memory. //
- extern pascal void SBGetModuleBounds(Rect *bounds, ModuleReference moduleRefNum)
- TWOWORDINLINE(0x70F9, 0xAAF2);
-
- /* Miscellaneous Utilities */
-
- // runs this (locked!) piece of code once within Extensions Strip's context.
- // PPC modules must pass a valid routine descriptor to this function. Since
- // the descriptor will not be disposed of after the code has executed, I would
- // recommend creating the descriptor (NewSBQueueProcProc) when sdevInitModule
- // is called and disposing it upon sdevCloseModule.
- // A non-zero result code means that the UPP could not be queued (memory error).
- // // May move memory! //
- extern pascal OSErr SBQueueCode(SBQueueUPP theProc, unsigned long refCon)
- TWOWORDINLINE(0x70F8, 0xAAF2);
-
- // sends the specified Apple Event within Extensions Strip's context to insure
- // safe sending rather than trusting that the front application is AE aware.
- // _SBSimpleAESend acts just like _AESend in that the AppleEvent you give to it
- // must still be disposed of afterward by your code to free up memory (even
- // though the event hasn't actually been sent yet.)
- //
- // _SBSimpleAESend is meant to be an easy way to send simple events. If you
- // need to check the reply AppleEvent or the _AESend error, ect., you should queue
- // your code (with _SBQueueCode or by having your module return 'sdevQueueModule')
- // and send the Apple Event yourself. The result returned by _SBSimpleAESend
- // is only non-zero if an error occured while queueing the event for later sending.
- //
- // Also, if an error does occur when Extensions Strip sends your AppleEvent, the
- // user will be notified with a dialog that _AESend failed.
- //
- // Here are the parameters I give to _AESend. They are basic enough for most
- // kinds of Apple Events that modules send, hence the name _SBSimpleAESend.
- // err = AESend(&theAppleEvent, &reply, // your specified AppleEvent
- // // and a dummy reply descriptor
- // kAENoReply + kAEAlwaysInteract + kAECanSwitchLayer, // send mode
- // kAENormalPriority, // send priority
- // kAEDefaultTimeout, // time out
- // nil, // idleProc
- // nil); // filterProc
- // // May move memory! //
- extern pascal OSErr SBSimpleAESend(const AppleEvent *theAppleEvent)
- TWOWORDINLINE(0x70F7, 0xAAF2);
-
- // returns a pointer to the current event being processed. Modififations to
- // the data in this pointer WILL take effect as the event gets passed along
- // to the other processes and jGNE filters further on in the chain. Although
- // a module can use this function at any time, it is really meant to be called
- // within the sdevInterceptedEvent selector because this is where a module can
- // deny other modules the proper processing of the event (such as in the case
- // of a keyDown.) Another good use for SBGetCurrentEvent() is to find the exact
- // point where a mouseDown occured if you have a queue of clickable objects.
- // // Will not move memory. //
- extern pascal EventRecord* SBGetCurrentEvent(void)
- TWOWORDINLINE(0x70F6, 0xAAF2);
-
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __EXTENSIONSSTRIP__ */